<?php

namespace App\Http\Controllers\Backend\Orders;

use App\ConstDir\ErrorConst;
use App\Http\Controllers\Backend\BaseController;
use App\Repository\Criteria\Orders\FormalOrderCriteria;
use App\Repository\Criteria\Orders\TestOrderCriteria;
use App\Repository\Models\OrderProductComment;
use App\Repository\Models\Orders;
use App\Repository\Repositories\Interfaces\ExamplesRepository;
use App\Repository\Repositories\Interfaces\OrderProductCommentRepository;
use App\Repository\Repositories\Interfaces\OrdersRepository;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;

/**
 * 订单评价
 *
 * @package App\Http\Controllers\Backend
 */
class OrderProductCommentController extends BaseController
{
    /**
     * @var OrderProductCommentRepository
     */
    protected $order_product_comment_repo;

    public function __construct(OrderProductCommentRepository $order_product_comment_repo)
    {
        $this->order_product_comment_repo = $order_product_comment_repo;
    }

    public function index()
    {
        $orders = $this->order_product_comment_repo->paginate($this->perPage);
        return $this->success(ErrorConst::SUCCESS_CODE, $orders, true);
    }

    public function show($id)
    {
        //
    }

    public function store()
    {
        //后台无订单创建
    }

    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'check_status' => 'integer|in:' . implode(',', array_keys(OrderProductComment::$check_status)),
        ]);
        $data = $request->all(['check_status']);

        $ret = $this->order_product_comment_repo->update($data, $id);

        return $this->noDataReturn($ret ? true : false);
    }

    public function delete($id)
    {
        //
    }
}
